/*
 * Author  : Pallab
 * Program : 657
 *
 * 2012-03-06 21:51:27
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")
template<class T>
inline void debug(T _x) {
    cout<<_x<<'\n';
}
template<class T1, class T2>
inline void debug(T1 _x,T2 _y) {
    cout<<_x<<' '<<_y<<'\n';
}
template<class T1, class T2, class T3>
inline void debug(T1 _x,T2 _y,T3 _z) {
    cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
template<class T1, class T2, class T3, class T4>
inline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {
    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
inline bool CI(int &_x) {
    return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
    return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
    return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}

const int maxn=50+5;
int R,C;
int caseno;
char grid[maxn][maxn];

vector< int >dices;
inline void Read() {
    fo(i,R) {
        fo(j,C) {
            cin>>grid[i][j];
        }
    }
}
int rr[]={-1,+1,+0,+0};
int cc[]={+0,+0,-1,+1};

int dots;//number of dots

#define block_it '.'
#define marked '*'

inline void go(int r,int c) {
    grid[r][c]=marked;
    fo(i,4) {
        int tr=r+rr[i];
        int tc=c+cc[i];
        if (tr<0||tc<0||tr>=R||tc>=C)continue;
        if (grid[tr][tc]=='.')continue;
        if ( grid[tr][tc]=='X') {
            go(tr,tc);
        }
    }
}
inline void dfs(int r, int c) {
    grid[r][c]=block_it;
    fo(i,4) {
        int tr=r+rr[i];
        int tc=c+cc[i];
        if (tr<0||tc<0||tr>=R||tc>=C)continue;
        if (grid[tr][tc]=='.')continue;
        if (grid[tr][tc]=='*') {
            dfs(tr,tc);
        }
        else if ( grid[tr][tc]=='X') {
            ++dots;
            go(tr,tc);
            dfs(tr,tc);
        }
    }
}
inline void Proc() {
    dices.clear();
    fo(i,R) {
        fo(j,C) {
            // if found a dice
            if (grid[i][j]=='*') {
                //initialize number of dost and run dfs
                dots=0;
                dfs(i,j);
                dices.pb(dots);
            }
        }
    }

    sort(dices.begin(),dices.end(),less<int>());
    cout<<"Throw "<<caseno;
    line;
    // print in accending order
    fo(i,SZ(dices)) {
        if (i!=0)cout<<' ';
        cout<<dices[i];
    }
    line;//give a new line
    line;//another new line

}
int main() {
    caseno=1;
    while ( CI(C,R) ) {
        if (R==0&&C==0)break;
        Read();
        Proc();
        ++caseno;
    }
}
